public class Text1 {
    public int searchInsert(int[] nums, int target) {
        int n = nums.length;
        int left = 0;
        int right = n - 1;
        int tmp = n;
        while(left<=right){
            int mid = ((right - left )>> 1) + left;
            if (target <= nums[mid]){
                tmp = mid;
                right = mid - 1;
            } else {
                left = mid + 1;
            }
        }
        return tmp;
    }
}
